# eric7.Plugins.CheckerPlugins.CodeStyleChecker.PathLib.PathlibChecker

Module implementing the checker for functions that can be replaced by use of the pathlib module.

### Global Attributes

None

### Classes

NameResolver | Class to resolve a Name or Attribute node.
PathlibChecker | Class implementing a checker for functions that can be replaced by use of the pathlib module.
PathlibVisitor | Class to traverse the AST node tree and check for potential issues.

### Functions

None

## NameResolver

Class to resolve a Name or Attribute node.

### Derived from

ast.NodeVisitor

### Class Attributes

None

### Class Methods

None

### Methods

NameResolver | Constructor
name | Public method to resolve the name.
visit_Attribute | Public method to handle the Attribute AST node.
visit_Name | Public method to handle the Name AST node.

### Static Methods

None

#### NameResolver (Constructor)

NameResolver(importAlias)

Constructor

importAlias (dict)
  reference to the import aliases dictionary

#### NameResolver.name

name()

Public method to resolve the name.

Return:
  resolved name

Return Type:
  str

#### NameResolver.visit_Attribute

visit_Attribute(node)

Public method to handle the Attribute AST node.

node (ast.Attribute)
  reference to the Attribute AST node

#### NameResolver.visit_Name

visit_Name(node)

Public method to handle the Name AST node.

node (ast.Name)
  reference to the Name AST node

Up

## PathlibChecker

Class implementing a checker for functions that can be replaced by use of the pathlib module.

### Derived from

CodeStyleTopicChecker

### Class Attributes

Category
Codes
Function2Code

### Class Methods

None

### Methods

PathlibChecker | Constructor
__checkForReplacement | Private method to check the given node for the need for a replacement.
__checkPathlibReplacement | Private method to check for pathlib replacements.

### Static Methods

None

#### PathlibChecker (Constructor)

PathlibChecker(source, filename, tree, selected, ignored, expected, repeat)

Constructor

source (list of str)
  source code to be checked
filename (str)
  name of the source file
tree (ast.Module)
  AST tree of the source code
selected (list of str)
  list of selected codes
ignored (list of str)
  list of codes to be ignored
expected (list of str)
  list of expected codes
repeat (bool)
  flag indicating to report each occurrence of a code

#### PathlibChecker.__checkForReplacement

__checkForReplacement(node, name)

Private method to check the given node for the need for a replacement.

node (ast.AST)
  reference to the AST node to check
name (str)
  resolved name of the node

#### PathlibChecker.__checkPathlibReplacement

__checkPathlibReplacement()

Private method to check for pathlib replacements.

Up

## PathlibVisitor

Class to traverse the AST node tree and check for potential issues.

### Derived from

ast.NodeVisitor

### Class Attributes

None

### Class Methods

None

### Methods

PathlibVisitor | Constructor
visit_Call | Public method to handle the Call AST node.
visit_Import | Public method to handle the Import AST node.
visit_ImportFrom | Public method handle the ImportFrom AST node.

### Static Methods

None

#### PathlibVisitor (Constructor)

PathlibVisitor(checkCallback)

Constructor

checkCallback (func)
  callback function taking a reference to the AST node and the resolved name

#### PathlibVisitor.visit_Call

visit_Call(node)

Public method to handle the Call AST node.

node (ast.Call)
  reference to the Call AST node

#### PathlibVisitor.visit_Import

visit_Import(node)

Public method to handle the Import AST node.

node (ast.Import)
  reference to the Import AST node

#### PathlibVisitor.visit_ImportFrom

visit_ImportFrom(node)

Public method handle the ImportFrom AST node.

node (ast.ImportFrom)
  reference to the ImportFrom AST node

Up